package com.jrx.anytxn.transaction.service;

import com.jrx.anytxn.common.exception.TxnBizException;
import com.jrx.anytxn.common.exception.TxnException;
import com.jrx.anytxn.number.exception.SegmentException;
import com.jrx.anytxn.transaction.bean.BillResult;
import com.jrx.anytxn.transaction.bean.RepaymentParamBean;
import com.jrx.anytxn.transaction.dto.payment.*;
import com.jrx.anytxn.transaction.entity.AmLoanAccountInfo;
import com.jrx.anytxn.transaction.entity.AmLoanMainInfo;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;


/**
 * 还款业务处理接口
 *
 * @author haopu.zheng
 * date  2019/7/26
 **/
public interface IPaymentService {

    /**
     * 逾期还款试算
     *
     * @param loanMainInfos 订单信息列表
     * @param loanAccountInfos 订单账户列表
     * @param paymentTrialReq  还款试算请求
     * @return 逾期试算返回
     * @author zhenghaopu
     * date: 2019/9/24 10:34
     */
    DelinquencyTrialRes overdueTrail(List<AmLoanMainInfo> loanMainInfos, List<AmLoanAccountInfo> loanAccountInfos, DelinquencyTrialReq paymentTrialReq) throws TxnBizException;

    /**
     * 提前结清还款试算
     *
     * @param loanMainInfos
     * @param loanAccountInfos
     * @param paymentTrialReq
     * @return
     * @throws TxnBizException
     */
    AdvanceSettleTrialRes preterminationTrail(List<AmLoanMainInfo> loanMainInfos, List<AmLoanAccountInfo> loanAccountInfos, PaymentTrialReq paymentTrialReq) throws TxnBizException;

    /**
     * 逾期还款
     *
     * @param delinquencyPaymentReq 逾期还款请求
     * @param repaymentParamBean    还款请求参数bean
     * @return 还款流水号
     * @author zhenghaopu
     * date: 2019/8/16 16:38
     */
    String overdueRepayment(DelinquencyPaymentReq delinquencyPaymentReq, RepaymentParamBean repaymentParamBean, Date bussinessDate) throws TxnBizException;

    /**
     * 提前结清还款
     *
     * @param paymentReq         还款请求
     * @param repaymentParamBean 还款请求参数bean
     * @return 还款流水号
     * @author zhenghaopu
     * date: 2019/8/16 16:38
     */
    String preterminationRepayment(PaymentReq paymentReq, RepaymentParamBean repaymentParamBean, Date bussinessDate) throws TxnBizException;

    /**
     * 还款状态查询
     *
     * @param paymentStatusQueryReq 还款状态查询req
     * @param customerId            客户ID
     * @return 还款状态查询res
     * @author : zhenghaopu
     * date: 2019/9/24 10:36
     */
    PaymentStatusQueryRes getPaymentStatus(PaymentStatusQueryReq paymentStatusQueryReq, String customerId) throws TxnBizException;

    /**
     * 提前还款还款试算
     *
     * @param loanMainInfo
     * @param loanAccountInfo
     * @param prePayTrialReq
     * @return
     * @throws TxnBizException
     */
    PrePayTrialRes prePayTrail(AmLoanMainInfo loanMainInfo, AmLoanAccountInfo loanAccountInfo, PrePayTrialReq prePayTrialReq) throws TxnException;

    /**
     * 提前还款
     *
     * @param prePayReq
     * @param repaymentParamBean
     * @return
     */
    String prePay(PrePayReq prePayReq, RepaymentParamBean repaymentParamBean, Date bussinessDate) throws TxnException;

    /**
     * 正常还款试算
     *
     * @param loanAccountInfos
     * @param onDuePayTrialReq
     * @return
     */
    OnDuePayTrialRes onDuePayTrial(List<AmLoanAccountInfo> loanAccountInfos, OnDuePayTrialReq onDuePayTrialReq) throws TxnBizException;

    /**
     * 正常还款
     *
     * @param onDuePayReq
     * @param repaymentParamBean
     * @return
     * @throws TxnBizException
     */
    String onDuePay(OnDuePayReq onDuePayReq, RepaymentParamBean repaymentParamBean, Date bussinessDate) throws TxnBizException;

    /**
     * 逾期欠款明细查询
     *
     * @param customerId 客户号
     * @param tenantId 租户id
     * @param channel 渠道
     * @return 逾期欠款明细
     */
    List<DelinquencyDebtDetailRes> queryDelinquencyDebtDetail(String customerId,String tenantId, String channel) throws TxnException;

    /**
     * 账单还款
     * @param billPayReq
     * @param repaymentParamBean
     * @param bussinessDate
     * @return
     */
    BillResult billPay(BillPayReq billPayReq, RepaymentParamBean repaymentParamBean, Date bussinessDate) throws TxnBizException;

    /**
     * 账单提前还下期
     * @param billPrepayNextReq
     * @param repaymentParamBean
     * @param bussinessDate
     * @return
     */
    BillResult billPrepayNext(BillPrepayNextReq billPrepayNextReq, RepaymentParamBean repaymentParamBean, Date bussinessDate) throws TxnException;

    /**
     * 退款
     * @param refundReq
     * @param repaymentParamBean
     * @param loanMainInfo
     * @param loanIdList
     * @throws Exception
     */
    void refund(RefundReq refundReq,RepaymentParamBean repaymentParamBean,AmLoanMainInfo loanMainInfo,List<String> loanIdList) throws Exception;
}
